<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<html>
<head>
<link href="<c:url value='/css/main.css'/>" rel="stylesheet"
	type="text/css" />
<fmt:setBundle basename="ApplicationResources" />
<title><fmt:message key="label.cruduser.maintain" /></title>
</head>
<body>
	<h1>
		<fmt:message key="label.cruduser" />
	</h1>
	<c:url var="url" scope="page" value="/controller/adduser">
		<c:param name="first_name" value="" />
		<c:param name="last_name" value="" />
		<c:param name="name" value="" />
		<c:param name="password" value="" />
		<c:param name="insert" value="true" />
	</c:url>
	<a href="${url}"><fmt:message key="label.cruduser.add" /></a>

	<br />
	<br />
	<table class="borderAll">
		<tr>
			<th><fmt:message key="label.cruduser.id" /></th>
			<th><fmt:message key="label.cruduser.name" /></th>
			<th><fmt:message key="label.cruduser.firstName" /></th>
			<th><fmt:message key="label.cruduser.lastName" /></th>
			<th><fmt:message key="label.cruduser.role" /></th>

			<th><fmt:message key="label.cruduser.edit" /></th>
			<th><fmt:message key="label.cruduser.delete" /></th>
		</tr>
		<c:forEach var="cruduser" items="${users}" varStatus="status">
			<tr class="${status.index%2==0?'even':'odd'}">
				<td class="nowrap">${cruduser.id}</td>
				<td class="nowrap">${cruduser.name}</td>
				<td class="nowrap">${cruduser.firstName}</td>
				<td class="nowrap">${cruduser.lastName}</td>
				<td class="nowrap">${cruduser.roleNames}</td>

				<td><c:url var="editurl" scope="page"
						value="/controller/edituser">
						<c:param name="id" value="${cruduser.id}" />
						<c:param name="insert" value="false" />
					</c:url> <a href="${editurl}"><fmt:message key="label.cruduser.edit" /></a></td>



				<td><c:url var="delurl" scope="page"
						value="/controller/deleteuser">
						<c:param name="id" value="${cruduser.id}" />
					</c:url> <c:if test="${sessionScope.user.id != cruduser.id}">
						<a href="${delurl}"><fmt:message key="label.cruduser.delete" /></a>
					</c:if> <c:if test="${sessionScope.user.id == cruduser.id}">
						<a href="#"><fmt:message key="label.cruduser.delete" /></a>
					</c:if></td>

			</tr>
		</c:forEach>



	</table>


</body>
</html>